<%--
  Created by IntelliJ IDEA.
  User: 凌某人
  Date: 2020/7/12
  Time: 17:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<form action="${pageContext.request.contextPath}/user/delete" method="get">
    <table>
        <thead>
        <tr>
            <th>
                <input type="checkbox"  class="all">
            </th>
            <th>ID</th>
            <th>名称</th>
            <th>密码</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${users}" var="user">
            <tr>
                <td>
                    <input type="checkbox" name="ids"  value="${user.id}">
                </td>
                <td>${user.id}</td>
                <td>${user.username}</td>
                <td>${user.password}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/user/update?id=${user.id}">修改</a>
                    <a href="${pageContext.request.contextPath}/user/delete?ids=${user.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
        <tfoot>
        <td colspan="5" align="center">
            <button type="submit">删除</button>
        </td>
        </tfoot>
    </table>
</form>
<script>
    let all = document.querySelector(".all");
    all.onchange=function () {
        let ids = document.querySelectorAll("tbody input[type=checkbox]");
        for (let  id of ids) {
            id.checked=all.checked;
        }
    }
</script>
</body>
</html>
